
function getQueryString(thisUrl,name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	//var r = window.location.search.substr(1).match(reg);
	var r1 = thisUrl.toString().split("?")[1];
	if(r1 != null){
		var r = r1.match(reg);
		if (r != null) return unescape(r[2]);
	}
	return null;

}

$(document).ready(function(){
	var signature = undefined;
	var server = "http://106.75.137.2:8088/lenong"
//	alert($('.money').val());
//  alert(window.location.href);

	//根据微信返回的CODE到lenong服务器兑换成登录信息
	$.loginWX = function(){
		var url = encodeURIComponent(window.location.href);
		console.log(url);
		var code = getQueryString(window.location.href,"code");

		$.ajax({
			type : "GET",
			url : server+"/wxUserLogin?code="+code+"&callback=?",
			dataType : "jsonp",
			jsonp: 'callback',
			success : function(json){
				console.log(json);
				$("body").text(json.user.accessToken);
			}
		});


	}
	$.loginWX();


});